﻿@using Pyramid.Models
@using Pyramid.Mvc.Html
@functions
{

	public string GetPartValue(int partId, StaffSalarySetMaster master)
	{
		if (master == null || master.StaffSalarySetDetails == null || master.StaffSalarySetDetails.Count == 0) return "X";
		var part = master.StaffSalarySetDetails.FirstOrDefault(x => x.PartId == partId);
		return part == null ? "X" : part.Value.ToString(part.SalaryPart.DisplayFormat);
	}

}
<div class="pageContent">
	@{
		var parts = (List<SalaryPart>) ViewBag.SalaryParts;
		var last = ViewBag.LastSet as StaffSalarySetMaster;
		var staffId = (int) ViewBag.StaffId;
	}
	@using (Html.BeginForm("Create", "StaffSalarySet", FormMethod.Post, new {@class = "pageForm required-validate", onsubmit = "return validateCallback(this, navTabAjaxDone);"}))
	{
		<div layouth="38">
			@Html.Hidden("staffId", staffId)
			<table class="table">
				<thead>
					<tr>
						<th width="160"></th>
						<th width="300">本次设定</th>
						<th width="240">上一次设定</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td class="title">操作日期</td>
						<td>@DateTime.Now.ToString("yyyy-MM-dd")</td>
						<td>@(last == null ? "无" : last.CreateTime.ToString("yyyy-MM-dd"))</td>
					</tr>
					<tr>
						<td class="title">生效日期</td>
						<td>@Html.DateField("effectiveDate", DateTime.Now.AddMonths(1).ToString("yyyy-MM-01"))</td>
						<td>@(last == null ? "" : last.EffectiveDate.ToString("yyyy年M月"))</td>
					</tr>
					@foreach (var part in parts)
					{
						<tr>
							<td class="title">@part.VariableName</td>
							<td>@Html.TextBox("part_" + part.Id, "", new {@class = "number"})</td>
							<td>@GetPartValue(part.Id, last)</td>
						</tr>
					}
					<tr>
						<td class="title">备注</td>
						<td>@Html.TextBox("remark")</td>
						<td>@(last == null ? "" : last.Remark)</td>
					</tr>
				</tbody>
			</table>
		</div>
		<div class="formBar">
			<ul>
				<li>
					<div class="buttonActive">
						<div class="buttonContent">
							<button type="submit">保存</button>
						</div>
					</div>
				</li>
				<li>
					<div class="button">
						<div class="buttonContent">
							<button type="button" class="close">取消</button>
						</div>
					</div>
				</li>
			</ul>
		</div>
	}
</div>